The_Johnsons - IrisCTF 2024
code:c
undefined8 main(void)
{
int iVar1;
long in_FS_OFFSET;
int local_84;
int local_80;
int local_7c;
long local_10;
local_10 = *(long *)(in_FS_OFFSET + 0x28);
puts("Welcome to the Johnson\'s family!");
puts(
"You have gotten to know each person decently well, so let\'s see if you remember all of the f acts."
);
puts("(Remember that each of the members like different things from each other.)");
local_84 = 0;
while (local_84 < 4) {
printf("Please choose %s\'s favorite color: ",nameslocal_84); __isoc99_scanf(&DAT_0010217c,local_78);
iVar1 = strcmp(local_78,colors);
if (iVar1 == 0) {
local_80 = 1;
LAB_00101449:
if ((((local_80 == chosenColors0) || (local_80 == chosenColors1)) || (local_80 == chosenColors2)) || (local_80 == chosenColors3)) { puts("That option was already chosen!");
}
else {
local_84 = local_84 + 1;
}
}
else {
iVar1 = strcmp(local_78,PTR_s_blue_00104048);
if (iVar1 == 0) {
local_80 = 2;
goto LAB_00101449;
}
iVar1 = strcmp(local_78,PTR_s_green_00104050);
if (iVar1 == 0) {
local_80 = 3;
goto LAB_00101449;
}
iVar1 = strcmp(local_78,PTR_s_yellow_00104058);
if (iVar1 == 0) {
local_80 = 4;
goto LAB_00101449;
}
puts("Invalid color!");
}
}
local_84 = 0;
do {
while( true ) {
if (3 < local_84) {
check();
if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) {
/* WARNING: Subroutine does not return */
__stack_chk_fail();
}
return 0;
}
printf("Please choose %s\'s favorite food: ",nameslocal_84); __isoc99_scanf(&DAT_0010217c,local_78);
iVar1 = strcmp(local_78,foods);
if (iVar1 != 0) break;
local_7c = 1;
LAB_0010159c:
if (((local_7c == chosenFoods0) || (local_7c == chosenFoods1)) || ((local_7c == chosenFoods2 || (local_7c == chosenFoods3)))) { puts("That option was already chosen!");
}
else {
local_84 = local_84 + 1;
}
}
iVar1 = strcmp(local_78,PTR_s_pasta_00104068);
if (iVar1 == 0) {
local_7c = 2;
goto LAB_0010159c;
}
iVar1 = strcmp(local_78,PTR_s_steak_00104070);
if (iVar1 == 0) {
local_7c = 3;
goto LAB_0010159c;
}
iVar1 = strcmp(local_78,PTR_s_chicken_00104078);
if (iVar1 == 0) {
local_7c = 4;
goto LAB_0010159c;
}
puts("Invalid food!");
} while( true );
}
code:c
void check(void)
{
byte bVar1;
bool bVar2;
if ((chosenFoods2 == 2) || (chosenFoods3 == 2)) { bVar2 = false;
}
else {
bVar2 = true;
}
if ((chosenColors0 == 3) || (chosenColors1 == 3)) { bVar1 = 0;
}
else {
bVar1 = 1;
}
if (chosenColors3 == 2 && (chosenFoods0 == 4 && (bool)((chosenColors1 != 1 && bVar2) & bVar1))))) { puts("Correct!");
system("cat flag.txt");
}
else {
puts("Incorrect.");
}
return;
}
code: shell
$ nc babyrevjohnson.chal.irisc.tf 10002
== proof-of-work: disabled ==
Welcome to the Johnson's family!
You have gotten to know each person decently well, so let's see if you remember all of the facts.
(Remember that each of the members like different things from each other.)
Please choose Alice's favorite color: red
Please choose Emma's favorite color: yellow
Please choose James's favorite color: green
Please choose William's favorite color: blue
Please choose Alice's favorite food: chicken
Please choose Emma's favorite food: pasta
Please choose James's favorite food: steak
Please choose William's favorite food: pizza
Correct!
やるだけ